﻿using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.GraphicsLibraryFramework;

namespace FirstWindow
{
    class MyGameWindow : GameWindow
    {
        public MyGameWindow()
            : base(GameWindowSettings.Default, 
                  new NativeWindowSettings 
                  { 
                      Size = new Vector2i(1280, 720),
                      Title = "First Window"
                  })
        {
        }

        protected override void OnLoad()
        {
            base.OnLoad();

            VSync = VSyncMode.Off;
            GL.Enable(EnableCap.DepthTest);
        }

        protected override void OnRenderFrame(FrameEventArgs args)
        {
            base.OnRenderFrame(args);

            GL.ClearColor(.1f, .1f, .2f, .9f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            Render();

            SwapBuffers();
        }

        private void Render()
        {
            // Your rendering code here
        }

        protected override void OnResize(ResizeEventArgs e)
        {
            base.OnResize(e);

            GL.Viewport(0, 0, e.Width, e.Height);
        }

        protected override void OnUnload()
        {
            base.OnUnload();
            //shader.Dispose();
        }
    }
}